const children = [

];
const routes = [

    //访问路由“/”,自动重定向到"/home"
    {
        path: '/',
        redirect: '/home'
    },
    {
        path: '/login',
        name: 'Login',
        component: () => import('@/views/login.vue')
    },
    {
        path: '/register',
        name: 'Register',
        component: () =>
            import ('@/views/register.vue')
    },
    //需求方路由
    {
        path: '/demand_home',
        name: 'demand_home',
        component: () => import('@/views/demand_home/demand_home.vue'),
        children:[
            {
                path: '/demand_home/demand_index',
                name: 'demand_index',
                component: () =>
                    import ('@/views/demand_home/demand_index.vue')
            },
            {
                path: '/demand_home/demand_upload',
                name: 'demand_upload',
                component: () =>
                    import ('@/views/demand_home/demand_upload.vue')
            },
            {
                path: '/demand_home/demand_task_design',
                name: 'demand_task_design',
                component: () =>
                    import ('@/views/demand_home/demand_task_design.vue')
            },
            {
                path: '/demand_home/demand_task_detail',
                name: 'demand_task_detail',
                component: () =>
                    import ('@/views/demand_home/demand_task_detail.vue')
            },
            {
                path: '/demand_home/demand_examine',
                name: 'demand_examine',
                component: () =>
                    import ('@/views/demand_home/demand_examine.vue')
            },
            {
                path: '/demand_home/demand_download',
                name: 'demand_download',
                component: () =>
                    import ('@/views/demand_home/demand_download.vue')
            },
            {
                path: '/demand_home/demand_feedback',
                name: 'demand_feedback',
                component: () =>
                    import ('@/views/demand_home/demand_feedback.vue')
            },
        ]
    },
    //标注方路由
    {
        path: '/home',
        name: 'home',
        component: () => import('@/views/home/home.vue'),
        children:[
            {
                path: '/home/anno_index',
                name: 'anno_index',
                component: () =>
                    import ('@/views/home/anno_index.vue')
            },
            {
                path: '/home/anno_info',
                name: 'anno_info',
                component: () =>
                    import ('@/views/home/anno_info.vue')
            },
            {
                path: '/home/anno_task_annotation',//任务标注页面
                name: 'anno_task_annotation',
                component: () =>
                    import ('@/views/home/anno_task_annotation.vue')
            },
            {
                path: '/home/anno_task_detail',//任务详情页面
                name: 'anno_task_detail',
                component: () =>
                    import ('@/views/home/anno_task_detail.vue')
            },
            {
                path: '/home/anno_feedback',//任务详情页面
                name: 'anno_feedback',
                component: () =>
                    import ('@/views/home/anno_feedback.vue')
            },
        ]
    },
    //管理员路由
    {
        path: '/admin_home',
        name: 'admin_home',
        component: () =>
            import ('@/views/admin_home/admin_home.vue'),
        children: [
            {
                path: '/admin_home/admin_index',
                name: 'admin_index',
                component: () =>
                    import ('@/views/admin_home/admin_index.vue')
            },
            {
                path: '/admin_home/admin_feedback',
                name: 'admin_feedback',
                component: () =>
                    import ('@/views/admin_home/admin_feedback.vue')
            },
            {
                path: '/admin_home/user_management',
                name: 'user_management',
                component: () =>
                    import ('@/views/admin_home/user_management.vue')
            },
            {
                path: '/admin_home/statistics',
                name: 'statistics',
                component: () =>
                    import ('@/views/admin_home/statistics.vue')
            },
        ]
    },
    {
        path: '/404',
        name: "NotFound",
        component: () => import('@/views/404.vue')
    }

];

export const existsRoute = (path) => {
    for (let i = 0; i < routes.length; i++) {
        const r = routes[i];
        if (r.path == path) {
            return true;
        }
        if (r.children && r.children.length) {
            for (let k = 0; k < r.children.length; k++) {
                const sr = r.children[k];
                if (sr.path == path) {
                    return true;
                }
            }
        }
    }
    return false;
};

export default routes;